{% extends "admin/base_site.html" %}

{% load admin_static django_rq i18n %}

{% block extrastyle %}
    {{ block.super }}
    <style>
        .data {
            display: inline-block;
            float: left;
            width: 80%;
            font-size: 12px;
            padding-top: 3px;
        }
    </style>
    <link href="{% static 'admin/css/forms.css' %}" type="text/css" rel="stylesheet">
{% endblock %}

{% block breadcrumbs %}
    <div class="breadcrumbs">
        <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> &rsaquo;
        <a href="{% url 'rq_home' %}">{% trans 'Django RQ' %}</a> &rsaquo;
        <a href = "{% url 'rq_jobs' queue_index %}">{{ queue.name }}</a> &rsaquo;
        <a href = "{% url 'rq_job_detail' queue_index job.id %}">{{ job.id }}</a>
    </div>
{% endblock %}

{% block content_title %}<h1>{% trans 'Job Info' %}</h1>{% endblock %}

{% block content %}

<div id="content-main">
    <fieldset class="suit-form module aligned ">
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'ID' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.id }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Queue' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.origin }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Timeout' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.timeout }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Result TTL' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.result_ttl }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Created At' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.created_at|to_localtime }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Enqueued At' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.enqueued_at|to_localtime }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Status' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.get_status }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Callable' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.func_name }}</p></div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Args' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7">
                <p class="form-control-static">
                    {% if job.args %}
                    <ul>
                        {% for arg in job.args %}
                            <li>{{ arg }}</li>
                        {% endfor %}
                    </ul>
                    {% endif %}
                </p>
            </div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Kwargs' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7">
                <p class="form-control-static">
                    {% if job.kwargs %}
                        <ul>
                            {% for key, value in job.kwargs.items %}
                                <li>{{ key }}: {{ value|escape }}</li>
                            {% endfor %}
                        </ul>
                    {% endif %}
                </p>
            </div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Exception' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7">
                <p class="form-control-static"><pre>{% if job.exc_info %}{{ job.exc_info|linebreaks }}{% endif %}</pre></p>
            </div>
        </div>
        <div class="form-group row form-row">
            <label class="form-control-label col-xs-12 col-sm-3 col-md-2"><label class="required">{% trans 'Result' %}</label></label>
            <div class="col-xs-12 col-sm-9 col-md-8 col-lg-7"><p class="form-control-static">{{ job.result }}</p></div>
        </div>
    </fieldset>
    <div class="submit-row">
        <p class="deletelink-box"><a href="delete/" class="deletelink">Delete</a></p>
        {% if job.is_failed %}
            <form method = 'POST' action = "{% url 'rq_requeue_job' queue_index job.id %}">
                {% csrf_token %}
                <input type="submit" value="Requeue" class="default" name="requeue">
            </form>
        {% endif %}
    </div>
</div>

{% endblock %}
